package servlet;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
//管理员登录
@WebServlet(name="uLoginServlet",urlPatterns = "/uLoginServlet")
public class uLoginServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out= response.getWriter();
        String num=request.getParameter("uNum");
        String name=request.getParameter("uName");
        String pwd=request.getParameter("uPwd");
        if(num.equals("31200") && name.equals("管理员") && pwd.equals("123451")){
            request.getRequestDispatcher("queryAllServlet").forward(request,response);
        } else {
            out.print("<script>alert('你不是管理员/信息错误');window.location.href='index.jsp'</script>" );
        }
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
